import { useState } from 'react'
// 变量响应式定义
function UseState1() {
  // useState只能存在于函数组件中

  let [count, setCount] = useState(0)
  function add() {
    setCount(count + 1)
    // useState不能嵌套在  if/for/其他函数中
    // if (count == 1) {
    //   let [name, setNmae] = useState('测试')  //报错
    // }
  }
  return (
    <>
      <p>{count}</p>
      <button onClick={() => add()}>点我+1</button>
    </>
  )
}
export default UseState1
